#!/bin/bash
echo "======= Install JDK====================="

v_jdk_path="/tmp/atwork/jdk-7u71-linux-x64.rpm";
#检查JDK是否安装
f_check_jdk_installed() {
	echo "check jdk version..."
	javac -version
	if [[ $? = 0 ]]; then
		echo "WARN: JDK alread installed"
		exit 1
	else
		echo "jdk has not installed, need to install jdk"	
	fi
}

#检查安装文件是否存在
f_check_install_source_exists(){
	if [ ! -f "$v_jdk_path" ]; then
		echo "JDK install Source not Exists, ${v_jdk_path}"
		exit 1
	fi
}

#安装JDK
f_install_jdk(){
        echo "installing jdk"
        `cd /tmp/atwork/`
        `rpm -ivh jdk-7u71-linux-x64.rpm`
        checkJdk
}


f_check_jdk_installed

f_check_install_source_exists

f_install_jdk



echo "======= Install JDK OK====================="

